From baac7d6eeaf522ff5faa28906cb1200e60a19c07 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Sat, 23 Jul 2022 15:31:45 +0200
Subject: fix(article): prevent TypeError on build

By switching to custom hooks for revalidating articles and comments,
everything was working on development mode but articles failed to build
for production.
---
 src/pages/article/[slug].tsx | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

(limited to 'src/pages/article/[slug].tsx')

diff --git a/src/pages/article/[slug].tsx b/src/pages/article/[slug].tsx
index 572a5fc..5036b5b 100644
--- a/src/pages/article/[slug].tsx
+++ b/src/pages/article/[slug].tsx
@@ -56,8 +56,11 @@ const ArticlePage: NextPageWithLayout<ArticlePageProps> = ({
 }) => {
   const { isFallback } = useRouter();
   const intl = useIntl();
-  const article = useArticle(slug, post);
-  const commentsData = useComments(post.id, comments);
+  const article = useArticle({ slug, fallback: post });
+  const commentsData = useComments({
+    contentId: article?.id,
+    fallback: comments,
+  });
   const { items: breadcrumbItems, schema: breadcrumbSchema } = useBreadcrumb({
     title: article?.title || '',
     url: `/article/${slug}`,
@@ -69,7 +72,7 @@ const ArticlePage: NextPageWithLayout<ArticlePageProps> = ({
 
   if (isFallback) return <Spinner />;
 
-  const { content, id, intro, meta, title } = article;
+  const { content, id, intro, meta, title } = article!;
   const { author, commentsCount, cover, dates, seo, thematics, topics } = meta;
 
   const headerMeta: PageLayoutProps['headerMeta'] = {
-- 
cgit v1.2.3

